/**
 * 医德医风管理子系统，医院评价功能模块
 * 
 * @Date: 2016-1-21
 * @author: Jackson wang
 * @version: 1.0
 * @since: 1.0
 */
define(
		[ "jquery", "datagridServ", "sysmanMain", "bizProto", "btnServ","ethicUtil",
				"msgServ", "flowInit", "buttonEvent", "deptUserSelect","dicWholeSubject" ],
		function($, datagridServ, sysmanMain, bizProto, btnServ,ethicUtil, msgServ,
				flowInit, buttonEvent, deptUserSelect,dicWholeSubject) {

			'use strict';

			var _typeUrl = '/dictionary/getTree.action', _rootpath,_bizProto,evaluate_type,
			// 评分详情url
			_initScoreListUrl = '/ethicEvaluate/query/getSubListDomainByMainId.action',
			// 编辑url
			_editUrl = '/ethicEvaluate/query/mainEditPage.action',
			
			_listUrl = '/getHosListDomain.action',

			_addScoreUrl = '/ethicEvaluate/query/getAddMinScore.action',
			// 评价列表url
			_evaluateUrlPre = '/ethicEvaluate/query', item_code_dic_id = 32, rootId = 'panel-hos-ethic-evaluation',
			// rootId = 'panel-self-ethic-evaluation',
			// rootId = 'panel-ethic-evaluation',
			edit_window_id = 'ethic-evaluation-win', editIndex = -1,

			editIndex1 = -1, editBegin = false, el_width = 300, el_big_width = 674, window_width = 900, window_height = 600, $activityListGrid,
			// 当前列表点击行号
			currentListIndex = -1,
			
			
			currentConfig = {
				//当前评价类型
				evaluate_name	: 'all',
				//当前评价代码
				evaluate_code	: 3,
				
				//下一状态标志
				NextStatus_code	: 4,			
				
				//记录锁定代码
				lock_code		: 5,
				
				
				
				//dom根节点id
				rootid			: 'panel-hos-ethic-evaluation',
				
				//子系统代码
							
				subSystemCode:'ethic',
				
				//业务模块代码
				moduleCode:'hosEthicEvaluate',
				
				//业务模块完整编码
				fullBizcode		: 'ethic:hosEthicEvaluate',
				
				//评分依据字段及当前打分字段
				sourceField		: 'dept_score',
				targetField		: 'composite_score'	,
				
				currentRow		: null
				
				
			},
			
			// 双击列表传递参数值
			_data,

			// 设置评价分类类别（按科室评价、全院评价、资料归档分类）
			classify_type,
			// 根据不同的分类，以便获得不同的属性
			tempcolumns,
			// 标记变量，让部门列表树初始化一次就不再初始化
			deptInitializd
			
			var public_method = {				

				/**
				 * 提交后执行
				 */
				afterSubmit : function(_options) {
					private_method.afterSubmit();
				},
				/**
				 * 提交前补充字表数据
				 */
				beforeSubmit : function(_options) {
					return private_method.beforeSubmit(_options)
				},
				/**
				 * 编辑页面初始化
				 */
				initEdit : function(_options) {
					private_method.initEdit(_options)
				},
				/**
				 * 初始化新增页面
				 * 
				 * @param _options.record
				 *            列表选中行
				 * @param _options.form
				 *            页面form对象
				 */
				initList : function(_options) {
					private_method.initList(_options);
				},

				/**
				 * @param _options.record
				 */

				closeWindow : function() {
					$('#' + edit_window_id).empty()
					var _moduleConfig = sysmanMain.getCurrentModuConfig();
					_moduleConfig.initParam = {
						editable : true
					};
					sysmanMain.setCurrentModuConfig(_moduleConfig);
				},

				reCreateField : function(_options) {
					private_method.reCreateField(_options)
				},
				rowDblClick : function(index, row) {
					private_method.rowDblClick(index, row)
				},
				buttonExtends : function(_options) {
					return {
						'自动院评' : function(e) {
							private_method.autoScore()
						},
						
						'批量提交' : function(e) {
							private_method.auditList()
						},
						'保存院评' : function(e) {
							private_method.save()
						},
						'查看' : function(e) {
							private_method.showDetail(_options)
						},
						'清除选择':function(e){
							var _grid = $('#'+currentConfig.rootid + ' .dg-list')
							if(_grid.length==1){
								_grid.datagrid('clearSelections');
							}
						}
						,
						'执行查询': function(e){
							
							var searchParam = ethicUtil.getSearchValue({rootId:currentConfig.rootid})
							if(searchParam && !$.isEmptyObject(searchParam)){
								private_method.getSerchValuation(searchParam);
							}
							if(e &&　e.currentTarget){
								$(e.currentTarget).linkbutton('enable');
							}
						}
						,
						'删除': function(e){
							
							var _grid = $('#'+currentConfig.rootid+ ' .dg-list')
							
							ethicUtil.del({target:_grid})
							if(e &&　e.currentTarget){
								$(e.currentTarget).linkbutton('enable');
							}
						}
					}
				}

			}

			var private_method = {
				

				// 获取加扣分详情
				initAddMinScoreList : function() {

					// 获取当前用户和考评期
					var _data = {
						uid : $('#' + edit_window_id + ' #person_code').val(),
						eval_year : $('#' + edit_window_id + ' #evaluate_year')
								.val()
					}

					var _url = '/ethicEvaluate/query/getAddMinScoreDetail.action';
					if (_data.uid && _data.eval_year) {
						_url += ("?uid=" + _data.uid + "&eval_year=" + _data.eval_year)
					}
					// html 中对应的div
					var _gridid = edit_window_id + ' div.evaluate-add-detail'
					var _grid = $('#' + _gridid)
					if (_grid.length == 1) {
						var _gridParam = {
							url : '/' + sysmanMain.getRootPath() + _url,
							idField : 'id',
							fitColumns : true,
							onLoadSuccess : function(data) {
								if (data && data.rows.length > 0) {
									datagridServ.mergeCellsByField({
										tableID : _gridid,
										colList : 'addorminus_type'
									})
								}
								// 显示加扣分分数总分
								// private_method.showAddMinScore(data);
							},
							onClickCell : private_method.editCell,
							columns : [ [ {
								field : 'addorminus_type',
								title : '分数类别',
								align : 'center',
								width : 20
							}, {
								field : 'item_name',
								title : '加扣分内容',
								width : 180,
								align : 'center'
							}, {
								field : 'score',
								title : '分数值',
								width : 20,
								align : 'center'
							} ] ]
						}
						$(_grid).datagrid(_gridParam)
					}

				},

				// 查看按钮
				showDetail : function(_options) {
					var _config = sysmanMain.getCurrentModuConfig();
					
					var $grid = $('#' + currentConfig.rootid + " .dg-list");
					var $edit_window = $('#' + edit_window_id);					

					var _url = '/'+sysmanMain.getRootPath()+'/'+currentConfig.moduleCode + '/query/editPage.action';
					
					var _param = {
						grid : $grid,
						window : $edit_window,
						href : _url,
						maximized : true,
						flag : true,
						existCheckElement : 'form'
					}
					
					datagridServ.windowEdit(_param);
				},

				// 显示总分数和考评日期
				showTotScoreAndDate : function(data) {
					if (data) {
						var tot_score = 0;
						for (var i = 0; i < data.rows.length; i++) {
							tot_score += data.rows[i].sub_score;
						}
						var current_date = new Date();
						$('#' + edit_window_id + ' #tot_score').textbox(
								'setValue', tot_score);
					}
				},

				save : function() {
					$activityListGrid = $('#' + currentConfig.rootid
							+ ' table.dg-list')
					$($activityListGrid).datagrid('acceptChanges');
					var _data = $($activityListGrid).datagrid('getData')

					if (_data && _data.rows) {
						// save data to remote

						var _url = '/' + sysmanMain.getRootPath()
								+ '/ethicEvaluate/saveList.action'
						$.ajax({
							url : _url,
							type : 'post',
							dataType : 'json',
							data : $.toJSON(_data.rows),
							contentType : 'appliction/json;charset=utf-8',
							success : function(data) {
								msgServ.Msgslide('操作成功');
							}
						})
					}
				},

				// 列表页面初始化
				initList : function(_options) {
					// 获取rootId
					if(window.console){
						console.log(' ethic hospital evaluate list loading...');
					}
					_bizProto = new bizProto({
						doc				: _options.doc,
						rootId			: currentConfig.rootid,
						panelSelector	: 'panel-title',
						subSystemCode	: 'ethic',
						moduleCode		: 'hosEthicEvaluate'
					});					
					
					// 获取ethicDeptRootId
					var gHeight = _bizProto.gridHeight;
					if(_options && _options.listHeightResize){
						gHeight += _options.listHeightResize
					}
					
					deptInitializd = false;
					if(window.console){
						console.log('init evaluate hospital')
					}
					//初始化部门用户树					
					private_method.initDeptUser({
						type 		: currentConfig.evaluate_name,
						gridHeight	: gHeight
					});
					
					//初始化评价数据列表
					private_method.typeClick({
						type 		: currentConfig.evaluate_name,
						gridHeight	: gHeight
					});
					
					$.messager.progress('close');
				},

				
				/**
				 * 评价类型监听事件
				 * 
				 * @param _options.type
				 *            评价类型
				 */
				typeClick : function(_options) {
					evaluate_type = _options.type
					private_method.initListGridRow(_options)
				},
				/**
				 * 初始化列表字段
				 * 
				 * @param _options.gridHeight
				 *            列表控件高度定义
				 */
				initListGridRow : function(_options) {
					
					var listTd = $('#' + currentConfig.rootid + ' td.list-btn');
			
					//加载列表按钮
					if(listTd && listTd.length>0){
						var _param = {
							bizcode:currentConfig.fullBizcode,
							rootPath:'/'+ sysmanMain.getRootPath(),
							container:listTd,
							callback:private_method.bindBtnEvent}
						btnServ.generateListBtn(_param);
					}else{
						private_method.bindBtnEvent()
					}
					
					// 搜索框
					var $searchbox=$('#'+ currentConfig.rootid + " input.searchbox")
					if($searchbox.length>0){
						
						var _searchParam = {
							prompt : '请输入查询条件',
							searcher : function(value, name) {
								var obj = {};
								obj.searchName=name;
								obj.searchValue=value;							
		//						private_method.doSearch(obj)
						}}
						
						//判断search菜单是否存在
						var $searchMenu = $('#'+ currentConfig.rootid + " div.search-mm")
						if($searchMenu.length>0){
							_searchParam.menu=$searchMenu
						}
						$($searchbox).searchbox(_searchParam);
					}
					
					var _gridParam = {
						height		: _options.gridHeight + 25,
						rownumbers : true,
						animate : true,
						striped : true,
						border : true,
						// singleSelect:false,
						idField : 'id',
						fitColumns : true,
						checkOnSelect : true,
						pagination : true,
						selectOnCheck : true,
						onClickCell : private_method.editCells,
						rowStyler: function(index,row){
							if(row && !(row.status==3) ){
								return 'background-color:#efefef;color:#666;'; 
							}
						}
						,
						toolbar	: $('#' + currentConfig.rootid + ' .tb-list')

					}
					var _columns = [ {
						field : 'ck',
						checkbox : true
					}, {
						field : 'bizno',
						title : '评价编号',
						width : 60,
						align : 'center'
					}, {
						field : 'evaluate_year',
						title : '考评年度',
						width : 30,
						align : 'center'
					}, {
						field : 'depart_name',
						title : '所在科室',
						width : 50,
						align : 'center'
					}, {
						field : 'person_name',
						title : '人员姓名',
						width : 30,
						align : 'center'
					},

					{
						field : 'evaluate',
						title : '自我评价',
						width : 100,
						align : 'center'
					}, {
						field : 'sel_score',
						title : '自评得分',
						width : 30,
						align : 'center'
					},

					{
						field : 'dept_score',
						title : '科室评分',
						width : 30,
						align : 'center'
					}, {
						field : 'dept_evaluate',
						title : '科室评价',
						width : 60,
						align : 'center',
						formatter: function(value,row,index){
							if(value){
								return '<span  title='+value+'>'+value+'</span>'  
							}else{
								return '';
							}  
	                    }
					}, {
						field : 'composite_score',
						title : '医院评分',
						width : 30,
						align : 'center',
						editor : 'text'
					}, {
						field : 'hospital_evaluate',
						title : '医院评价',
						width : 40,
						align : 'center',
						editor : 'text' ,
						formatter: function(value,row,index){
							if(value){
								return '<span  title='+value+'>'+value+'</span>'  
							}else{
								return '';
							}
	                    }
					}, {
						field : 'show_score',
						title : '评价等级',
						width : 40,
						align : 'center',
						formatter : function(value, row, index) {
							if (row.composite_score >= 95) {
								return "优秀";
							} else if (row.composite_score >= 85) {
								return "良好";
							} else if (row.composite_score >= 65) {
								return "一般";
							} else if (row.composite_score >= 0) {
								return "差";
							} else {
								return "差";
							}
						}
					},{
						field : 'status',
						title : '当前状态',
						width : 60,
						align : 'center',
						formatter: function(value,row,index){
							
							if (row.status){
								return ethicUtil.getListStatus({status:row.status});
							}
						}

					}

					]

					
					var _url = '/' + sysmanMain.getRootPath() + _evaluateUrlPre
							+ _listUrl;
					_gridParam.url = _url
					_gridParam = $.extend({}, _gridParam, {
						columns : [ _columns ]
					})
					tempcolumns = _columns;
					var _listGrid = $('#' + currentConfig.rootid + ' table.dg-list')
					$activityListGrid = $(_listGrid).datagrid(_gridParam)

				},

				/**
				 * 初始化部门
				 * 
				 * @param _options.type
				 * 			评价数据类别参数
				 * @param _options.gridHeight
				 * 			评价数据列表控件高度值
				 */
				initDeptUser : function(_options) {
					var $dept = $('#' + currentConfig.rootid + ' div.tg-department');

					classify_type = _options.type

					var deptTreeUrl = "/honest/department/query/getTreeListByJobDept.action";
					// 部门信息
					if ($dept && $dept.length > 0) {
						if (!deptInitializd) {
							$dept
									.treegrid({
										height		: _options.gridHeight + 70,
										rownumbers : true,
										animate : true,
										idField : 'id',
										treeField : 'name',
										striped : true,
										border : true,
										fitColumns : true,
										
										width : el_width,
										url : deptTreeUrl,
										onClickRow : private_method.getClassifyValuation,
										columns : [ [ {
											field : 'name',
											title : '部门名称',
											width : 60,
											halign : 'center'
										} ] ]
									})
						}

					}
					deptInitializd = true;

				},

				/**
				 * 按照条件（部门）分别获取医德评价信息
				 */
				getClassifyValuation : function(row) {
					var _url = _listUrl;
					var _gridParam = {
						rownumbers : true,
						animate : true,
						striped : true,
						border : true,
						// singleSelect:false,
						idField : 'id',
						fitColumns : true,
						checkOnSelect : true,
						pagination : true,
						selectOnCheck : true,
						onClickCell : private_method.editCells

					};
					_gridParam.url = '/' + sysmanMain.getRootPath()
							+ _evaluateUrlPre + _url;
					_gridParam.queryParams = {
						condition : {
							depart_code : row.id
						}
					}

					_gridParam = $.extend({}, _gridParam, {
						columns : [ tempcolumns ]
					})

					var _listGrid = $('#' + currentConfig.rootid + ' table.dg-list')
					$activityListGrid = $(_listGrid).datagrid(_gridParam)

				},
				
				/**
				 * 按照条件获取医德评价信息
				 */
				getSerchValuation : function(_param) {

					var _url = _listUrl;

					var _gridParam = {
						rownumbers : true,
						animate : true,
						striped : true,
						border : true,
						// singleSelect:false,
						idField : 'id',
						fitColumns : true,
						checkOnSelect : true,
						pagination : true,
						selectOnCheck : true,
						onClickCell : private_method.editCells

					};
					_gridParam.url = '/' + sysmanMain.getRootPath()
							+ _evaluateUrlPre + _url;
					_gridParam.queryParams = {
						condition : _param
					}
					_gridParam = $.extend({}, _gridParam, {
						columns : [ tempcolumns ]
					})
					var _listGrid = $('#' + currentConfig.rootid + ' table.dg-list')
					$activityListGrid = $(_listGrid).datagrid(_gridParam)

				},

				// 编辑页面初始化
				initEdit : function(_options) {
					// 评价人员姓名及科室
					if (_data) {
						$('#' + edit_window_id + ' form.main-form').form(
								'load', _data)
						_data = null
					}
					
					// 初始化评分表
					private_method.initScoreList();
					// 初始化加扣分详情
					private_method.initAddMinScoreList();
				},

				
				afterSubmit : function() {
					$('#' + currentConfig.rootid + ' table.dg-list').datagrid('reload')
					private_method.initScoreList();

				},
				// 初始化评分表
				initScoreList : function() {
					if (window.console) {
						console.log('initScoreList loaded and starting... ')
					}
					var _url
					var _idVal = $('#' + edit_window_id + ' #lobid').val()
					if (!_idVal || _idVal == '') {
						_url = _initScoreListUrl;
					} else {
						_url = _initScoreListUrl + '?lobid=' + _idVal
					}

					var _gridid = edit_window_id + ' div.evaluate-sub'
					var _grid = $('#' + _gridid)
					if (_grid.length == 1) {
						var _gridParam = {
							url : '/' + sysmanMain.getRootPath() + _url,
							striped : true,
							border : true,
							nowrap : false,
							// singleSelect:false,
							idField : 'id',
							fitColumns : true,
							onLoadSuccess : function(data) {
								if (data && data.rows.length > 0) {
									datagridServ.mergeCellsByField({
										tableID : _gridid,
										colList : 'item_name'
									})
									private_method.showTotScoreAndDate(data);
								}
							},

							onClickCell : private_method.editCell,
							columns : [ [
							// {field:'ck',checkbox:"true"},
							{
								field : 'item_name',
								title : '项目类别',
								align : 'center',
								width : 80
							}, {
								field : 'sub_content',
								title : '考评内容',
								width : 120,
								align : 'center'
							}, {
								field : 'sub_score',
								title : '单项分值',
								width : 20,
								align : 'center'
							}, {
								field : 'sel_score',
								title : '自评得分',
								width : 20,
								align : 'center'
							}, {
								field : 'evaluate_result',
								title : '考评情况',
								width : 60,
								align : 'center'
							} ] ],
							onAfterEdit : function(index, row, changes) {
								private_method.afterEdit(index, row, changes)
							},
							onEndEdit : function(index, row, changes) {
								private_method.afterEdit(index, row, changes)
							}

						}
						$(_grid).datagrid(_gridParam)
					}
				},
				rowDblClick : function(index, row) {

					var editWindow = edit_window_id;
					var _param = {}
					var _moduleConfig = sysmanMain.getCurrentModuConfig();
					if (!_moduleConfig) {
						_moduleConfig = {}
					}

					var _param = {
						index : index,
						row : row,
						rootId : currentConfig.rootid,
						editWindow : edit_window_id,
						// moduleConfig:sysmanMain.getCurrentModuConfig(),传入空值，自动取当前模块配置
						url : _editUrl,
						maxWindowSize : true,
						width : window_width,
						height : window_height
					}
					// 暂存选中行
					_data = row

					// 设定当前选中行
					currentListIndex = index
					buttonEvent.doubleClickEdit(_param)

				},
				beforeSubmit : function(_options) {
					var _gridid = edit_window_id + ' div.evaluate-sub'
					if (editBegin) {
						$('#' + _gridid).datagrid('acceptChanges');
						$('#' + _gridid).datagrid('endEdit', editIndex);
						editIndex = -1;
					}
					var _data = $('#' + _gridid).datagrid('getData')

					/**
					 * 未进入编辑状态，强行触发分数统计
					 */
					if (!editBegin) {
						private_method.afterEdit()
					}
					if (_data && _data.rows) {
						return {
							sublist : $.toJSON(_data.rows)
						}
					}
				},
				editCell : function(index, field, value) {
					if (window.console)
						console.info(' editCell fired ...')
					var _gridid = edit_window_id + ' div.evaluate-sub'

					if (field == 'sel_score' || field == 'evaluate_result'
							|| field == 'dept_score') {
						if (!editBegin) {
							editBegin = true
						}
						$('#' + _gridid).datagrid('beginEdit', index);

						if (editIndex > -1 && (editIndex != index)) {
							editIndex = index
						}

					}
				},

				editCells : function(index, field, value) {
					$activityListGrid = $('#' + currentConfig.rootid + ' .dg-list')
					
					var rows = $activityListGrid.datagrid('getRows');
					var _row ;
					
					if(rows && rows[index]){
						_row = rows[index];
						currentConfig.currentRow = _row;
					}
					
					if (window.console)
						console.info(' editCells fired ...')
					if (field == 'composite_score' || field == 'hospital_evaluate') {
						if(_row && _row.status){
							var _status = parseInt(_row.status)
							 if(_status ===currentConfig.evaluate_code){
							 	
							 	dicWholeSubject.openPopPage({
							 		grid	:$activityListGrid,
							 		id		:_row.id,
							 		data	: _row.hospital_evaluate_detail==null?null:$.parseJSON(_row.hospital_evaluate_detail),
							 		callback:private_method.saveWholeDetail
							 	})
							 	
							 	//启用行内编辑
//								if (editIndex1 > -1 && (editIndex1 != index)) {
//									$($activityListGrid).datagrid('acceptChanges');
//									$($activityListGrid)
//											.datagrid('endEdit', editIndex1);
//								}
//		
//								$($activityListGrid).datagrid('beginEdit', index);
//								editIndex1 = index
							}
						}

					}
				},
				
				saveWholeDetail :function(_options){
					
					var _url = '/'+sysmanMain.getRootPath() + '/hosEthicEvaluate/saveWholeDetail.action';
					
					var whole_change_score = 0,whole_evaluate
					
					if(_options.data){
						$.each(_options.data,function(j,o){
							if(o.whole_score){
								
								var _score = parseFloat(o.whole_score)
								if(o.item_type==='加分'){
									whole_change_score +=_score;
									
									var te = o.name + '加' + o.whole_score + '分';
									whole_evaluate = whole_evaluate==null?te :whole_evaluate +','+te;
								}else{
									_score = Math.abs(_score);
									whole_change_score -=_score
									
									var te = o.name + '扣' + _score + '分';
									whole_evaluate = whole_evaluate==null?te : whole_evaluate + ',' + te
								}
							}
						})
					}
					//根据自评分计算科评分
					var dept_score = parseFloat(currentConfig.currentRow.dept_score);
					var whole_score = dept_score + whole_change_score
					
					
					var data = {
							id:_options.id,
							whole_evaluate_detail:$.toJSON(_options.data),
							composite_score :whole_score,
							hospital_evaluate:whole_evaluate
					}
					
					//执行查询
					$.ajax({
						url			: _url,
						data		: data,
						type 		: 'post',
						contentType	: "application/x-www-form-urlencoded; charset=UTF-8",
						dataType 	: 'json',
						success		: function(data){
							msgServ.Msgslide('院评操作成功。');
							$('#' + currentConfig.rootid + ' table.dg-list').datagrid('reload');
						},
						error : function(jqXHR, textStatus, errorThrown) {
							// $.messager.alert('提示','加载失败,请重新刷新页面');	
							
							msgServ.Msgslide('操作失败,请重新刷新页面，如果问题仍旧存在，请联系系统管理员处理。');
						}
					
					})
					
				},

				afterEdit : function(index, row, changes) {
					if (window.console) {
						console.log('afterEdit fired ...')
					}
					var _grid = $('#' + edit_window_id + ' div.evaluate-sub')
					var countScore = 0.0

					if (_grid.length == 1) {
						var _data = $(_grid).datagrid('getData')
						if (_data && _data.rows) {
							$.each(_data.rows, function(i, row) {
								if (row.sel_score)
									countScore += parseFloat(row.sel_score)
							})
						}
					}

					private_method.setCountScore(countScore)

				},
				/**
				 * 自动评分
				 * 
				 */
				autoScore : function() {
					var target_grid = $('#' + currentConfig.rootid + ' .dg-list');
					
					var sourceField = currentConfig.sourceField;
					
					var targetField = currentConfig.targetField;
					
					if (target_grid && target_grid.length == 1) {
	
						var _grid = target_grid
						// 合计分数
						var countScore = 0.0
						var _records = $(target_grid).datagrid('getRows')
	
						$.each(_records, function(i, record) {
							if ((record.status == currentConfig.evaluate_code) && record[sourceField]) {
								record[targetField] = record[sourceField]
								countScore += parseFloat(record[sourceField]);
							}
						})
	
						$(target_grid).datagrid('loadData', _records)
						private_method.setCountScore(countScore)
					}
				},
				setCountScore : function(val) {
					var _countEl = $('#' + edit_window_id + ' #sel_score')
					if (_countEl.length == 1) {
						$(_countEl).textbox('setValue', val.toFixed(1))
					}
				},

				auditOne : function() {
					var _auditVal = currentConfig.NextStatus_code, 
					
					target_grid = $('#' + currentConfig.rootid + ' table.dg-list');

					var _id = $('#' + edit_window_id + ' #id')
					var _idVal
					if (_id.length == 1) {

						_idVal = $(_id).val()
						// id为空
						if (!_idVal || _idVal == '') {
							msgServ('请先保存考评记录')
							return

						}
					}

					var _auditUrl = '/' + sysmanMain.getRootPath()
							+ '/ethicEvaluate/auditOne.action'

					$.messager.confirm('警告', '提交后将无法修改考评内容，确定执行操作?',
							function(r) {

								if (r) {
									var _data = {
										id : _idVal,
										status : _auditVal
									}
									var _param = {
										url : _auditUrl,
										data : _data,
										success : function(data) {
											msgServ.Msgslide('提交操作成功');

											$(target_grid).datagrid(
													'clearSelections')
											$(target_grid).datagrid('load')
											$('#' + edit_window_id).window(
													'close')

										},
										error : function() {
											msgServ.Msgslide('提交操作失败');
										}
									}
									$.ajax(_param)
								}
							})

				},
				/**
				 * 批量提交考评记录
				 */
				auditList : function() {
					//dom根节点
					var tempRootId = currentConfig.rootid;
					
					// 保存修改
					var target_grid = $('#' + tempRootId + ' .dg-list');
					if (editBegin) {
						$(target_grid).datagrid('acceptChanges');
						$(target_grid).datagrid('endEdit', editIndex);
						editIndex = -1;
					}
									
					
					//下一节点状态值					
					var _auditVal = currentConfig.NextStatus_code;
					
					//当前节点状态值
					var _curStatus = currentConfig.evaluate_code
					
					//调用批量提交考评记录方法
					ethicUtil.auditList({
						rootId:tempRootId,
						auditVal:_auditVal,
						valStandard:_curStatus
					})
				}
				,
				//绑定按钮事件
				bindBtnEvent:function(){
					
					var btn = $('#'+currentConfig.rootid + ' div.tb-list a.function-btn')
					
					// 绑定按钮事件
					
					//判断按钮是否存在
					if(btn.length>0){
						$(btn).unbind('click');
						$(btn).bind('click', private_method.function_btn_listenner)	
					}
					
					//执行查询按钮事件绑定					
					btn = $('#'+currentConfig.rootid + ' form.condition-form a.conditon-search')
					if(btn.length>0){
						$(btn).unbind('click');
						$(btn).bind('click', private_method.function_btn_listenner)	
					}
					
				}
				,
				function_btn_listenner:function(evt){
					btnServ.applyButton({buttonEvt:evt,buttonConfig:public_method.buttonExtends()})
				}

			}

			return public_method;

		});